<div class="row">
     <div class="col-xs-12 col-xs-12">
          <div class="widget radius-bordered">
              <div class="widget-header bg-blue">
				<i class="widget-icon fa fa-arrow-down"></i>
				<span class="widget-caption">使用人员编辑</span>
				<div class="widget-buttons">
					<a href="#" data-toggle="maximize">
						<i class="fa fa-expand"></i>
					</a>
					<a href="#" data-toggle="collapse">
						<i class="fa fa-minus"></i>
					</a>
					<a href="#" data-toggle="dispose">
						<i class="fa fa-times"></i>
					</a>
				</div>
			</div>
              <div class="widget-body">
                   <form id="YstechForm" action="" method="post" class="form-horizontal"
                                                  data-bv-message=""
                                                  data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                                                  data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                                                  data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
                  <neq name="cache.id" value=""><input type="hidden" name="id" value="{$cache.id}"></neq>
                  <div class="form-title">
                        <a href="{:U('Cms/Locks/orderlist',array('p'=>$p))}" class="btn btn-primary" data-loader="Ystech-loader" data-loadername="使用人员管理">
							<i class="fa fa-mail-reply"></i>返回
						</a>
                   </div>
				   
                   <div class="form-group">
                        <label class="col-lg-2 control-label">用户</label>
                        <div class="col-lg-4">
                        <neq name="cache.id" value="">
                        <p style="padding-top:5px;">{$cache.username} {$cache.mobile}</p>
                        <else/>
                        <a id="choose_user" class="btn btn-primary">选择</a>
                        <p id="user_name" style="padding-top:7px;display:inline-block; margin-left:5px;"></p>
                        <input type="hidden" name="UserID" value="">
                        </neq>
                        </div>
                   </div>
                   
				   <div class="form-group">
                        <label class="col-lg-2 control-label">载体</label>
                        <div class="col-lg-4">
                        <neq name="cache.id" value="">
                        <p style="padding-top:5px;">{$cache.Name}【绑定智能锁{$cache.LockId}】</p>
                        <else/>
                        <select name="CarrierId" class="form-control input-sm"><foreach name="carrierinfo" item="vo"><option value='{$vo.SerialNo}'>{$vo.Name}【绑定智能锁{$vo.LockId}】</option></foreach></select>
                        </neq>
                        </div>
                   </div>
                   
                   <div class="form-group">
                        <label class="col-lg-2 control-label">生效日期</label>
                        <div class="col-lg-4">
                        <input type="text" id="EffectiveTime" name="EffectiveTime" class="form-control" value="<neq name='cache.EffectiveTime' value=''>{$cache.EffectiveTime}</neq>">
                        </div>
                   </div>
                   <div class="form-group">
                        <label class="col-lg-2 control-label">失效日期</label>
                        <div class="col-lg-4">
                        <input type="text" id="ExpiryTime" name="ExpiryTime" class="form-control" value="<neq name='cache.ExpiryTime' value=''>{$cache.ExpiryTime}</neq>">
                        </div>
                   </div>
                   
				   <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                             <button class="btn btn-primary btn-lg" type="submit">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;
                             <button class="btn btn-palegreen btn-lg" type="reset">重填</button>
                        </div>
                    </div>
                   </form>
                </div>
        </div>
	</div>
     
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h5 class="modal-title" id="myModalLabel">搜索用户</h5>
            </div>
            <div class="modal-body">
            	<div class="form-group">
                     <input type="text" id="search_user" name="search_user" class="form-control" style="width:70%; display:inline-block" value="">  <a id="search-btn" class="btn btn-primary">搜索</a>
                </div>
                <div id="user_tab" class="form-group">
                	 
                </div>    	
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>-->
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<!--面包屑导航封装-->
<div id="tmpbread" style="display: none;">{$breadhtml}</div>
<script type="text/javascript">
	setBread($('#tmpbread').html());
</script>
<!--/面包屑导航封装-->

<!--表单验证与提交封装-->
<script type="text/javascript">
	$('#choose_user').on('click', function(){
		$('#myModal').modal();
	})
	
	$('#search-btn').on('click', function(){
		search_user = $('#search_user').val();
		if(!search_user) return false;
		$('input[name="UserID"]').val('');
		url = '/Locks/usertab?search='+encodeURIComponent(search_user);
		$('#user_tab').load(url,0,function(){
			$('#Ystech-table .Ystech-check').off().on('click',function(){
//				$('#Ystech-table .Ystech-check').removeAttr("checked");
				if($(this).is(":checked")){
					$(this).parent().parent().parent().parent("tr").siblings("tr").find(".Ystech-check").removeAttr("checked");
					$('input[name="UserID"]').val($(this).val());	
					$('#user_name').html($(this).parent().parent().parent().next("td").html()+' '+$(this).parent().parent().parent().next("td").next("td").html());	
				}else{
					$('input[name="UserID"]').val('');
					$('#user_name').val("");	
				}
				
//				$('#search_user').val($('input[name="UserID"]').val());
			});
			
		}); 
	})
	
	
	$('#EffectiveTime').datetimepicker({format:"yyyy-mm-dd hh:ii:ss",autoclose:1});
	$('#ExpiryTime').datetimepicker({format:"yyyy-mm-dd hh:ii:ss",autoclose:1});

	$('#YstechForm').bootstrapValidator({
		submitHandler: function (validator, form, submitButton) {
			
			<eq name="cache.id" value="">
			if(!$('select[name="CarrierId"]').val()){
				$.Ystech.alert('danger','请选择载体！');
				return false;
			}
			
			if(!$('input[name="UserID"]').val()){
				$.Ystech.alert('danger','请选择用户！');
				return false;
			}
			</eq>
			if(!$('input[name="EffectiveTime"]').val()){
				$.Ystech.alert('danger','请填写生效日期！');
				return false;
			}
			
			if(!$('input[name="ExpiryTime"]').val()){
				$.Ystech.alert('danger','请填写失效日期！');
				return false;
			}
			
           	var tourl="{:U('Cms/Locks/order')}";
			var data=$('#YstechForm').serialize();
			$.Ystech.ajax('post',tourl,data,null);
			return false;
        },
	});
	
	
</script>
<!--/表单验证与提交封装-->
